<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    public function show(){
    	return "zaixllkii";
    }

    public function edit($id){
    	echo "编辑用户".$id;
    }

    public function delete($id){
    	// echo "删除用户".$id;
    	return route('udelete',['id'=>$id]);
    }
    // public

    public function comment($id){
    	return '评论成功'.$id;
    }

    public function qinqiu(Request $request){
    	// $method = $request->method();
    	$res = $request->isMethod('post'); 
    	var_dump($res);
    }

    public function fshow(){
    	return view('upload');
    }

    public function fupload(Request $request){
    	//检测文件是否上传
    	$res = $request->hasfile('ffup');
    	if($res){
    		//相对路劲，相对正在请求的路径
    		$request->file('ffup')->move('./upload','jiaju.jpg');
    	}

    	// var_dump($res);
    }

    // cookie操作
    public function setcookie(Request $request){
    	//创建cookie1,Cookie前的‘\’不能少
    	// \Cookie::queue('name','crh',20);//时间单位是分钟
    	//创建cookie2 response('')->withCookie('key','value'10);
    	// 读取cookie 1
    	// $res = \Cookie::get('name');
    	//读取cookie 2
    	$res = $request->cookie('name');
    	var_dump($res);
    }


    //闪存

    public function flash(){
    	return view('flash');
    }

    public function doflash(Request $request){
    	// var_dump($request->all());
    	$request->flash();//将请求来的参数 都闪存起来
    	return back();
    }

    public function old(){
    	var_dump(old('uname'));
    }


    //响应
    public function response(){
        //json
        // return response()->json(['name'=>'123','pwd'=>'abc']);
        //下载
        // return response()->download('upload/jiaju.jpg');
        $kind = ['id'=>1,'kind'=>'lover','name'=>'zaixllkii'];
        return view('kind.index',['kind'=>$kind]);

        // redirect()
    }

}
